import {
	IsEmail,
	IsInt,
	IsMobilePhone,
	IsOptional,
	IsPositive,
	Length,
	Max,
	MaxLength,
	Min,
} from "class-validator";

export class Item {
	id: number;
	name: string;
	age: number;
	email: string;
	mobile: string;
	introduction?: string;
}

export class BaseSearchQuery {
	searchText?: string;
}

export class PaginationQuery extends BaseSearchQuery {
	@IsInt()
	@IsPositive()
	@Min(1)
	@IsOptional()
	pageIndex?: number = 1;

	@IsInt()
	@IsPositive()
	@Min(1)
	@IsOptional()
	pageSize?: number = 10;
}

export class CreateItemDto {
	@Length(2, 20)
	name: string;
	@Min(10)
	@Max(100)
	age: number;
	@IsEmail()
	email: string;
	@IsMobilePhone("zh-CN")
	mobile: string;
	@MaxLength(300)
	introduction?: string;
}
